/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.agilelang.structure;

import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.ArrayList;
import java.util.List;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Marshaller;

/**
 *
 * @author Roderick
 */
public class CreateConfig {

    public static void config_controller() {
        AppConfig config = new AppConfig();
        List<FileStatic> files = new ArrayList<>();
        files.add(new FileStatic("style.css", "static/style.css"));
        //files.add(new FileStatic("index.php", "index.php"));
        config.file = files;
        //config.structure = "folder.zip";

        config.directory.add("model");
        config.directory.add("controller");
        config.directory.add("view");
        config.directory.add("static");

        JAXBContext jc = null;
        Marshaller marshaller;
        java.io.StringWriter sw = new StringWriter();
        try {
            jc = JAXBContext.newInstance(AppConfig.class);
            marshaller = jc.createMarshaller();
            marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
            marshaller.marshal(config, sw);
        } catch (JAXBException ex) {
            System.out.println("Error --> " + ex.toString());
        }
        try {
            String path_xml = "E:\\agile\\AgileLang\\Test\\_app.xml";
            PrintWriter pw = new PrintWriter(new BufferedWriter(new FileWriter(path_xml)));
            System.out.println(path_xml);
            pw.print(sw.toString());
            pw.close();
        } catch (IOException e) {
        }
    }

    public static void main(String ar[]) {
        config_controller();
    }
}
